  //点击获取验证码
  $('.getcode').click(function(){
    var phone=$('.phone').val();
    if(phone==""){
        layer.msg('请输入手机号码');
        return false;
    }else if(!(/^1[34578]\d{9}$/.test(phone))){
        layer.msg('手机号码格式有误，请重新填写');
        return false;
    }else{
        $.ajax({
            type: "POST",
            url: $host+'/api/open/common/sendCode',
            data: {
                "phone":phone,
                type:3
            },
            async: true,
            dataType:'json',
            success: function(result){
                console.log(result);
                codeButton();
            },
            error:function(){
                console.log('获取验证码错误')
            }
        });
    }
})
function codeButton(){
    var code = $(".getcode");
    getCode();
    code.attr("disabled","disabled");
    setTimeout(function(){
        code.css("color","#DBDBDB");
    },1000)
    var time = 60;
    var set=setInterval(function(){
        time ===0?'':time--;
        code.text("重新获取"+time+'s');
    }, 1000);
    setTimeout(function(){
        code.attr("disabled",false).text("重新获取验证码");
        clearInterval(set);
    }, 60000);
}
//点击绑定
$('.btn_dl').click(function(){
    var phone=$('.phone').val();
    var code=$('.code').val();
    if(phone==''){
        layer.msg('请输入手机号码');
        return false;
    }else if(!(/^1[34578]\d{9}$/.test(phone))){
        layer.msg('手机号码格式有误，请重新填写');
        return false;
    }else if(code==''){
        layer.msg('请输入验证码');
        return false;
    }else{
         $.ajax({
            type: "POST",
            url: $host+'/api/open/thirdBind',
            data: {
                phone:$('.phone').val(),
                code:$('.code').val()
            },
            async: true,
            dataType:'json',
            success: function(result){
                //绑定手机号成功，跳转首页
                // window.location.href="index.html";
            },
            error:function(){
                console.log('绑定手机号接口错误')
            }
        });
    }
})